using Pairingproject2._3.UI;
using System;
using Pairingproject2._3.Fractions;
using System.Collections.Generic;
using System.Linq;
using System.Data;

namespace Pairingproject2._3.GenerateTheTitle
{
    public class Generatethetitle
    {   
        //生成题目****************//
        //Random表示伪随机数生成器
        Random random = new Random();
        string[] operatorA = new string[2] { "+", "-" };
        string[] operatorB = new string[4] { "+", "-", "*", "/" };
        string[] operatorC = new string[4] { "+", "-", "*", "/"};
        public string[] Randomgenerationoperator(char type) //按年级随机生成运算符///////////////////
        {
            if (type == 'A') //
            {
                return operatorA;
            }
            else if (type == 'B') //
            {
                return operatorB;
            }
            return operatorC;
        }

        public int RandIntegerGeneate(int integer) //随机生成自然数////////////////
        {
            int number = random.Next(0, integer);
            if (number < 0) number = 0;
            return number;
        }

        static Fraction FractionPartialResult(Fraction A, Fraction B, int sym) // 两个分数的四则运算//sym用来判断执行什么运算
        {
            if (sym == 100) return (A + B);
            else if (sym == 101) return A - B;
            else if (sym == 102) return A * B;
            else if (sym == 103) return A / B;
            else return A ^ B;
        }

        /**********判断与之前的题目是否重复************///未实现

        public string[] PuzzleGenerate(int N, char type) //生成N个四则表达式//////////////////////////11111111111111111111111
        {
            var op = Randomgenerationoperator(type);
            string[] topic = new string[N];
            for (int i = 0; i < N; i++)
            {
                string Tm="";
                for (int j = 0; j < 3; j++)
                {
                    int num = RandIntegerGeneate(op.Length);//获得字符串
                    Tm += RandIntegerGeneate(10).ToString() + op[num];                 
                };
                Tm += RandIntegerGeneate(10).ToString();//补位
                topic[i] = Tm;
            }
            return topic;  
        }
    }

}
